<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%><spring:message
	code="app.searchPlaceholder" var="searchPlaceholder" htmlEscape="true" />
<div class="row-fluid census-searchrow">
	<div class="span12">
		<center>
			<form id="searchForm" class="form-search">
				<input type="text" name="q" id="q"
					class="search-query census-search60"
					placeholder="${searchPlaceholder}" /> <a id="searchBtn"
					class="btn btn-primary"> <i class="icon-search icon-white"></i>
				</a> <a id="addBtn" class="btn" href="/census#add"> <i
					class="icon-search icon-plus"></i> </a>
			</form>
		</center>
	</div>
</div>
<div class="row-fluid">
	<div id="search-container" class="span12"></div>
</div>
<script type="text/javascript">
	require([ 'jquery', 'app', 'i18n!nls/messages', 'mustache',
			'text!templates/search.html', 'domReady!' ], function($, app, bdl,
			m, searchTmpl) {
		$('a#addBtn').click(function(e) {
			app.go('/census/entry');
		});
		$('a#searchBtn').click(function(e) {
			$.ajax({
				url : '/census/search',
				type : 'GET',
				dataType : 'json',
				data : $('form#searchForm').serialize()
			}).success(function(data) {
				$("div#search-container").html(function() {
					return m.render(searchTmpl, $.extend(data, bdl));
				});
			});
		});
	});
</script>